package com.bangdao.app.jetpacktest.jetpack.lifecycle;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.bangdao.app.jetpacktest.R;

public class LifecycleActivity1 extends AppCompatActivity {

    private MediaPlayerListener1 mediaPlayerListener1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_lifecycle);

        mediaPlayerListener1 = new MediaPlayerListener1();
        //初始化播放器
        mediaPlayerListener1.initMedia();
    }

    @Override
    protected void onResume() {
        super.onResume();

        //开始播放
        mediaPlayerListener1.startPlayMedia();
    }

    @Override
    protected void onPause() {
        super.onPause();

        //停止播放
        mediaPlayerListener1.pausePlay();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        //销毁播放器
        mediaPlayerListener1.destroyPlay();
    }
}